﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MuaChungDAO;
using MuaChungDAO;
using MuaChungDTO;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace MuaChungDAO
{
    public class DonHangHandler
    {
        public static DataTable napTatCa()
        {
            return NhomMuaHandler.napTongQuat("select * from DonHang");
        }

        public static DataTable napTheoDealId(string dealId)
        {
            return NhomMuaHandler.napTongQuat("select * from DonHang where DealId = " + dealId);
        }

        /*
         * (chỉ đếm chưa xác nhận và đã xác nhận, không đếm đã hủy)
         */
        public static int demSoNguoiMuaCuaDeal(string dealId)
        {
            DataTable dt = new DataTable();
            dt = NhomMuaHandler.napTongQuat("select * from DonHang where DealId = " + dealId + " and TrangThai != 2");

            return dt.Rows.Count;
        }

        private DonHangDAO data = new DonHangDAO();
        private DonHangDTO info = new DonHangDTO();

        public ArrayList getDsDonHang()
        {
            return data.getDsDonHang();
        }

        public ArrayList getDsDonHangTheoId(string id)
        {
            return data.getDonHangTheoID(id);
        }
    }
}
